﻿using System;
using System.Windows;


namespace Parking
{
    /// <summary>
    /// Логика взаимодействия для who.xaml
    /// </summary>
    public partial class Who
    {
        public Who(DBBase db,MainWindow parent, bool type = true)
        {
            InitializeComponent();
            _tp = type;
            _db = db;
            _par = parent;
        }

        private readonly MainWindow _par;
        private readonly bool _tp;
        private readonly DBBase _db;
        private void Button1Click(object sender, RoutedEventArgs e)
        {
            _db.WriteData(textBox1.Text, int.Parse(textBox3.Text), textBox2.Text, textBox4.Text, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), (_tp ? 0 : 1), textBox5.Text);
            _par.Upd();
            Close();
            
        }

        private void Button2Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void textBox1_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (textBox1.Text.Length == 6) textBox3.Focus();
        }
        
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            textBox1.Focus();
        }
     }
}
